﻿using Com.JunCaiSoft.DBContext;
using Com.JunCaiSoft.Permission.Dao;
using Com.JunCaiSoft.Permission.IDao;
using Com.JunCaiSoft.Web;
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Identity;
using Microsoft.AspNetCore.Mvc.ApplicationModels;
using Microsoft.EntityFrameworkCore.Storage;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.DependencyInjection.Extensions;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;

namespace Com.JunCaiSoft.Permission.ResourceExtension
{
    public static class NoticeSystemServiceCollectionExtension
    {
        public static IServiceCollection AddPermission(this IServiceCollection services)
        {
            //添加用户相关注入
            services.TryAddSingleton<IUserDao>(new UserDao(services.BuildServiceProvider().GetService<MSSQLDbContext>()));
            //services.TryAddTransient<IUserDao,UserDao>();
            //services.TryAddScoped<IUserDao, UserDao>();

            //添加角色相关注入
            services.TryAddSingleton<IRoleDao>(new RoleDao(services.BuildServiceProvider().GetService<MSSQLDbContext>()));
            //services.TryAddSingleton<IRoleDao>(new RoleDao(services.BuildServiceProvider().GetService<JunCaiDbContext>()));
            //services.TryAddScoped<IRoleDao, RoleDao>();

            //添加岗位相关注入
            services.TryAddSingleton<IPositionDao>(new PositionDao(services.BuildServiceProvider().GetService<MSSQLDbContext>()));
            //services.TryAddSingleton<IRoleDao>(new RoleDao(services.BuildServiceProvider().GetService<JunCaiDbContext>()));
            //services.TryAddScoped<IRoleDao, RoleDao>();
            return services;
        }
    }
}
